package com.test.demo;

import com.test.demo.component.HelloComponent;
import com.test.demo.configuration.HelloConfiguration;
import com.test.demo.controller.HelloController;
import com.test.demo.model.Student;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import com.test.demo.repository.HelloRepository;
import org.springframework.context.annotation.ComponentScan;

//设置扫描路径
//@ComponentScan({"com.test.demo"})
@SpringBootApplication
public class SpringIocDemoApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(SpringIocDemoApplication.class, args);
//		HelloComponent component = context.getBean(HelloComponent.class);
//		HelloConfiguration configuration = context.getBean(HelloConfiguration.class);
//		HelloController controller = context.getBean(HelloController.class);
//		HelloRepository repository = context.getBean(HelloRepository.class);
//		component.print();
//		configuration.print();
//		controller.print();
//		repository.print();

//		HelloComponent component = (HelloComponent) context.getBean("helloComponent");
//		component.print();

//		HelloComponent component = context.getBean("helloComponent",HelloComponent.class);
//		component.print();

//		Student student1 = context.getBean("st1",Student.class);
//		Student student2 = context.getBean("st2",Student.class);
//		Student student  = context.getBean("st",Student.class);
//		System.out.println(student1);
//		System.out.println(student2);
//		System.out.println(student);

//		context.getBean(HelloComponent.class).getStudent6();

		context.getBean(HelloRepository.class).getStudent1();
		context.getBean(HelloRepository.class).getStudent2();




	}

}
